<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>sort</title>
</head>

<body>
  <script>
    let a = ["ant", "Bug", "cat", "Dog"]
    // 不区分大小写顺序排序
    let c = a.sort(function (s, t) {
      // console.log(s);
      let a = s.toLowerCase();
      let b = t.toLowerCase()
      console.log(a, b)

      if (a < b) return -1;
      if (a > b) return 1;
      return 0
    })
    console.log(c);
  </script>
</body>

</html>